package com.ruoyi.business.modbus.domain;

import java.io.Serializable;

/**
 * Modbus主站设备抽象基类
 * 
 * @author ruoyi
 * @date 2024-01-01
 */
public abstract class ModbusMasterDevice implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 设备编码 */
    private String deviceSN;

    /** 设备名称 */
    private String deviceName;

    /** 超时时间(毫秒) */
    private Integer timeout = 6000;

    /** 重试次数 */
    private Integer retries = 3;

    public ModbusMasterDevice() {}

    public ModbusMasterDevice(String deviceSN, String deviceName, Integer timeout, Integer retries) {
        this.deviceSN = deviceSN;
        this.deviceName = deviceName;
        this.timeout = timeout;
        this.retries = retries;
    }

    /**
     * 获取设备类型
     */
    public abstract String getDeviceType();

    // Getters and Setters
    public String getDeviceSN() {
        return deviceSN;
    }

    public void setDeviceSN(String deviceSN) {
        this.deviceSN = deviceSN;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public Integer getTimeout() {
        return timeout;
    }

    public void setTimeout(Integer timeout) {
        this.timeout = timeout;
    }

    public Integer getRetries() {
        return retries;
    }

    public void setRetries(Integer retries) {
        this.retries = retries;
    }

    @Override
    public String toString() {
        return "ModbusMasterDevice{" +
                "deviceSN='" + deviceSN + '\'' +
                ", deviceName='" + deviceName + '\'' +
                ", deviceType='" + getDeviceType() + '\'' +
                ", timeout=" + timeout +
                ", retries=" + retries +
                '}';
    }
}
